package com.gp.learn.common.core.mybaitsplus.mapper;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SupperMapper<T> extends BaseMapper<T> {

    /**
     * 对Wrapper进行扩展 list 查询
     *
     * @param wrapper
     * @return
     */
    @Select("select ${ew.select} from ${ew.tableName} as ${ew.tableAlias} ${ew.joinSql} ${ew.customSqlSegment}")
    List<Map<String, Object>> selectListMap(@Param(Constants.WRAPPER) Wrapper<T> wrapper);

    /**
     * 对Wrapper进行扩展 分页查询
     *
     * @param wrapper
     * @return
     */
    @Select("select ${ew.select} from ${ew.tableName} as ${ew.tableAlias} ${ew.joinSql} ${ew.customSqlSegment}")
    IPage<Map<String, Object>> pageList(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> wrapper);
}
